[#include "../../dbadminer/common/html.ftl" /]
[@html]
    [@head title="编辑连接" css=["fw"] /]
    [@body]
        [@formMain ]
            <div class="fw-forms">
                 [@dataForm formId="form-connect-edit" ]
                    <input id="connectId" type="hidden" name="id" value="${connect.id!}" />
                     <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                         <label class="is-required">连接类型：</label>
                         <select class="am-radius" name="type" required>
                             <option value="">-- 请选择 --</option>
                             [#list dict.getType("db_connect_type") as dict]
                                 [#if dict.dictValue == connect.type ]
                                     <option value="${dict.dictValue!}" selected>${dict.dictLabel}</option>
                                 [#else]
                                     <option value="${dict.dictValue!}">${dict.dictLabel}</option>
                                 [/#if]
                             [/#list]
                         </select>
                     </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <label class="is-required">连接名称：</label>
                        <input class="am-form-field am-radius" type="text" name="name" value="${connect.name!}" required/>
                    </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-6 am-u-lg-4">
                        <label class="is-required">主机：</label>
                        <input class="am-form-field am-radius" type="text" name="host" value="${connect.host!}" required/>
                    </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <label class="is-required">端口号：</label>
                        <input class="am-form-field am-radius" type="text" name="port" value="${connect.port!}" required/>
                    </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <label class="is-required">初始数据库：</label>
                        <input class="am-form-field am-radius" type="text" name="database" value="${connect.database!}" required/>
                    </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <label class="is-required">用户名：</label>
                        <input class="am-form-field am-radius" type="text" name="username" value="${connect.username!}" required/>
                    </div>
                    <div class="am-form-group am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <label class="is-required">密码：</label>
                        <input class="am-form-field am-radius" type="text" name="password" value="${connect.password!}" required/>
                        <span class="toggleBtn"></span>
                    </div>
                 [/@dataForm]
            </div>
        [/@formMain]

        [@rightToolbar /]

        [@script js=["fw", "validate"] progress="false" ]
            <script type="text/javascript">
                var prefix = ctx + "osfw/dbadminer/connect";

                $("#form-config-edit").validate({
                    rules: {

                    },
                    messages: {
                    },
                    onkeyup: false,
                    focusCleanup: true
                });

                function submitHandler() {
                    if ($.validate.form()) {
                        $.operate.save(prefix + "/edit", $('#form-connect-edit').serialize());
                    }
                }
            </script>
        [/@script]
    [/@body]
[/@html]